﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EmployeeModule.EmployeeMain
{
    /// <summary>
    /// Interaction logic for EmployeeMainView.xaml
    /// </summary>
    public partial class EmployeeMainView : UserControl, IEmployeeMainView
    {
        public EmployeeMainView()
        {
            InitializeComponent();
            this.LostFocus += new RoutedEventHandler(EmployeeDetailView_LostFocus);
            this.GotFocus += new RoutedEventHandler(EmployeeDetailView_GotFocus);
        }

        void EmployeeDetailView_GotFocus(object sender, RoutedEventArgs e)
        {
            IsActive = true;
        }

        void EmployeeDetailView_LostFocus(object sender, RoutedEventArgs e)
        {
            IsActive = false;

        }

        #region IActiveAware Members

        protected override void OnGotFocus(RoutedEventArgs e)
        {
            base.OnGotFocus(e);

            IsActive = true;
        }

        protected override void OnLostFocus(RoutedEventArgs e)
        {
            base.OnLostFocus(e);

            IsActive = false;
        }

        private bool _isActive = false;
        public bool IsActive
        {
            get
            {
                return _isActive;
            }
            set
            {
                if (_isActive != value)
                {
                    _isActive = value;
                    IsActiveChanged(this, EventArgs.Empty);
                }
            }
        }

        public event EventHandler IsActiveChanged = delegate { };

        #endregion
    }
}
